package com.visual.android;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.p2p.WifiP2pManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public final class StrUtils {
    private static final String TAG = "Visual";
    private static int msgIndex = 0;

    public static void resetMsgIndex() {
        msgIndex = 0;
    }
    public static String formatMsg(String action, String result) {
        Log.d(TAG,action + " => " + result);
        msgIndex++;
        return "\n\n" + msgIndex + ". " + getTimeStr() + "\n\t" + action +"\n\t=>" + result;
    }

    public static String formatMsg(String action, int result) {
        Log.d(TAG,action + " => " + result);
        return "\n\n" + msgIndex + ". " + getTimeStr() + "\n\t" + action +"\n\t=>" + result;
    }

    public static String formatMsg(String action, long result) {
        Log.d(TAG,action + " => " + result);
        return "\n\n" + msgIndex + ". " + getTimeStr() + "\n\t" + action +"\n\t=>" + result;
    }

    private static String getTimeStr() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS", Locale.US);
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String timeString = formatter.format(curDate);
        return timeString;
    }
}


